package com.clps.cn.Activite03;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.repository.ProcessDefinitionQuery;

import java.util.List;

/**
 * 查询流程定义的信息
 */
public class QueryProcessDefinition {

    public static void main(String[] args) {

        //01得到ProcessEngline对象
        ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine();

        //02:创建RepositoryService对象
        RepositoryService repositoryService = defaultProcessEngine.getRepositoryService();

        //03:ProcessDeFINTIONQuery对象
        ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();

        //04:设置条件，并根据查询的所有流程定义 查询流程定义的key = tables
        List<ProcessDefinition> list = processDefinitionQuery.processDefinitionKey("holiday")
                .orderByProcessDefinitionVersion()
                .desc().list();

        //05:输出流程定义的信息
        for (ProcessDefinition processDefinition : list) {
            System.out.println("processDefinition.getId() = " + processDefinition.getId());
            System.out.println("processDefinition.getName() = " + processDefinition.getName());
            System.out.println("processDefinition.getKey() = " + processDefinition.getKey());
            System.out.println("processDefinition.getVersion() = " + processDefinition.getVersion());
            System.out.println("processDefinition.getDeploymentId() = " + processDefinition.getDeploymentId());

        }
    }
}
